// $Id: GeneralPreferencePage.java 87 2012-02-29 22:49:36Z huijzer@gmail.com $
package lime.application.preference;

import lime.Activator;
import lime.common.UIUtils;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class GeneralPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {

	public static final String APPLICATION_DEFAULT_PERSPECTIVE = "application.default.perspective";
	public static final String APPLICATION_SAVE_STATE = "application.save.state";

	public GeneralPreferencePage() {
		super(GRID);
	}

	@Override
	protected void createFieldEditors() {
		String[][] entryNamesAndValues = UIUtils.getPerspectives();
		ComboFieldEditor defaultPerspective = new ComboFieldEditor(APPLICATION_DEFAULT_PERSPECTIVE,
				"Default perspective", entryNamesAndValues, getFieldEditorParent());
		addField(defaultPerspective);

		BooleanFieldEditor saveState = new BooleanFieldEditor(APPLICATION_SAVE_STATE, "Save state",
				getFieldEditorParent());
		addField(saveState);
	}

	@Override
	public void init(IWorkbench workbench) {
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
	}
}